package 语言特性学习;

import org.junit.Test;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * Description
 *
 * @Author: SunAo
 * @Date: 2022/4/11 15:02
 */
public class 大数计算 {


    @Test
    public void 四舍五入(){
        BigDecimal bigDecimal = new BigDecimal(1.998);
        System.out.println(bigDecimal.setScale(0,BigDecimal.ROUND_DOWN));
    }

    @Test
    public void dd(){
        long amount = 3323;
        System.out.println(new BigDecimal(amount/100f).setScale(2, RoundingMode.HALF_DOWN).toString());
    }

    @Test
    public void 向上取整(){
        long amount = 33239;
        System.out.println(new BigDecimal(amount/1000f).setScale(2, BigDecimal.ROUND_UP).toString());
    }
}
